package com.gwtexp.client.mvp;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.gwtexp.client.ClientFactory;
import com.gwtexp.client.place.GoodbyePlace;
import com.gwtexp.client.place.HelloPlace;
import com.gwtexp.client.presenter.GoodbyeActivity;
import com.gwtexp.client.presenter.HelloActivity;

public class AppActivityMapper implements ActivityMapper {
	private ClientFactory clientFactory;

	public AppActivityMapper(ClientFactory clientFactory) {
		super();
		this.clientFactory = clientFactory;
	}

	@Override
	public Activity getActivity(Place place) {
		if (place instanceof HelloPlace)
			return new HelloActivity((HelloPlace) place, clientFactory);
		else if (place instanceof GoodbyePlace) return new GoodbyeActivity((GoodbyePlace) place, clientFactory);
		return null;
	}
}
